﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="sideBar_right.ascx.cs"
    Inherits="sideBar_right" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<div class="side_bar">
    <div class="side_top">
        Thể loại</div>
    <div class="side_content">
        <!-- begin loop -->
        <asp:Repeater ID="rpt_sideBarR" runat="server">
            <ItemTemplate>
                <p>
                    <span class="gachDauDong"></span><a id="catesa" href='<%#URLHelper.BuildURLCATE("chi-tiet",Eval("TenCate_E").ToString())%>'>
                        <%# Eval("TenCate") %></a>
                    <%--<a id="catesa" href='<%#Eval("idCategory","~/../details.aspx?c={0}")%>'><%# Eval("TenCate") %></a>--%>
                </p>
            </ItemTemplate>
        </asp:Repeater>
        <!-- end loop -->
        <p>
            <span class="gachDauDong"></span>
            <%--<a id="catesa" href="~/../details.aspx">Tất cả Danh mục</a>--%>
            <a id="catesa" href="<%=URLHelper.BuildURLCATE("chi-tiet","tat-ca") %>">Tất cả Danh
                mục</a>
        </p>
    </div>
    <div class="side_bot">
    </div>
</div>
<div class="side_bar">
    <div class="side_top">
        Tìm kiếm</div>
    <div class="side_content">
        <br />
        <b>Tôi cần tìm 1 người sẽ </b>
        <asp:TextBox CssClass="search2" ID="textSearch" runat="server"></asp:TextBox>
        <ajaxToolkit:FilteredTextBoxExtender ID="TextBox1_FilteredTextBoxExtender" runat="server"
            FilterMode="InvalidChars" InvalidChars="!@#$%^&amp;*()_-+=\|{}[]&quot;':,&lt;&gt;.?/"
            TargetControlID="textSearch">
        </ajaxToolkit:FilteredTextBoxExtender>
        <br />
        <asp:DropDownList CssClass="search23" ID="dropSearch" runat="server" OnSelectedIndexChanged="dropSearch_SelectedIndexChanged">
        </asp:DropDownList>
        <br />
        <div class="timkiemR">
            <asp:LinkButton ID="LinkButton1" CssClass="btnTimRieng" runat="server" OnClick="LinkButton1_Click"
                TabIndex="56" OnClientClick="return ktra()"> Tìm kiếm </asp:LinkButton>
        </div>
        <br />
    </div>
    <div class="side_bot">
    </div>
</div>
<div class="side_bar">
    <div class="side_top">
        Yêu cầu công việc</div>
    <div class="side_content">
        <span style="display:none" id="totalRecords"></span>
        <div id="result">
            <ul class="timviec-item">
            </ul>
        </div>
        <div id="paging" style="padding:5px">
        </div>
    </div>
    <div class="side_bot">
    </div>
</div>
<script type="text/javascript">
    $(function () {
        var text2 = "Nhập nôi dung cần tìm";
        $(".search2").val(text2);
        $(".search2").focus(function () {
            //if($(".search2").val() == text2)
            $(this).val("");
            //$(this).css("border","1px #8bc33d solid");
        });

        $(".search2").blur(function () {
            if ($(this).val() == "")
                $(this).val(text2);
            //$(this).css("border","1px #d9dada solid");
        });
    });
    function ktra() {
        if ($(".search2").val() == "Nhập nôi dung cần tìm") {
            alert('Hãy nhập nội dung bạn cần tìm');
            $(".search2").focus();
            return false;
        }
    }

    var pageSize = 5;
    $(document).ready(function () {
        $.ajax({
            type: "POST",
            url: "../details.aspx/FetchGigRequest",
            data: "{skip:0,take:" + pageSize + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            async: true,
            cache: false,
            success: function (msg) {
                var total = msg.d.TotalRecords;
                if (total > 0) {
                    printCustomer(msg);
                    $("#paging").text("");
                    // Get the page count by dividing the total records
                    // by the page size. This has to be rounded up
                    // otherwise you might not get the last page
                    var pageTotal = Math.ceil(total / pageSize);
                    for (var i = 0; i < pageTotal; i++) {
                        //$("#paging").append("<a href='" + i + 1 + "' onClick=\"pageData(" + (i + 1) + ")\">" + (i + 1) + "</a>&nbsp;");
                        $("#paging").append("<a class=\"timviec-pager\" href='" + (i + 1) + "'>" + (i + 1) + "</a>&nbsp;");
                    }
                }
                else {
                    $("#paging").text("No records were found.");
                }
                $("#totalRecords").text("Total records: " + total);
            }
        });
        $(".timviec-pager").live("click", function () {
            var id = $(this).attr("href");
            //var skip = e == 1 ? 0 : (e * pageSize) - pageSize;
            var skip = id == 1 ? 0 : (id * pageSize) - pageSize;
            $.ajax({
                type: "POST",
                url: "../details.aspx/FetchGigRequest",
                data: "{skip:" + skip + ",take:" + pageSize + "}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: true,
                cache: false,
                success: function (msg) {
                    printCustomer(msg);
                }
            });
            return false;
        })
    });

    // This function accepts a customer object
    // and prints the results to the div element.
    function printCustomer(msg) {
        $("#result ul li").remove();
        var customers = msg.d.GigRequestJsons;
        for (var i = 0; i < customers.length; i++) {
            //        <li><span><a href="idAcc">
            //                    nhathn786
            //                </a>cần :</span><br>
            //                    b
            //                </li>
            var str = "";
            str += "<li><span><a href=\"idAcc\"> " + customers[i].UserName + " </a>cần :</span> <br />" + customers[i].Required + "</li>";
            $("#result ul").append(str);
        }
    } 
</script>
